/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       timed_event.h

	$Header: /game/timed_event.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( TIMED_EVENT_H_INCLUDED )
#define TIMED_EVENT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <cassert>

#include "discrete_event.h"

// --------------------------------------------------------------------------
// t_timed_event class
// --------------------------------------------------------------------------

class t_timed_event : public t_discrete_event
{
public:
	// Constructor/Destructor
	t_timed_event();
	virtual ~t_timed_event() = 0;

	// Member functions
	int		get_first_occurrence() const;
	int		get_recurrence_interval() const;
	bool	is_active_on_day( int day ) const;
	void	set_first_occurrence( int new_first_occurrence );
	void	set_recurrence_interval( int new_recurrence_interval );

protected:
	// Member functions
	bool	read( std::streambuf & stream, int version );
	bool	read_from_map( std::streambuf & stream, int format_version );
	bool	write( std::streambuf & stream ) const;

private:
	// Data members
	int	m_first_occurrence;
	int	m_recurrence_interval;
};

// --------------------------------------------------------------------------
// t_timed_event inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_timed_event::t_timed_event()
	:	m_first_occurrence( 0 ),
		m_recurrence_interval( 0 )
{
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_timed_event::~t_timed_event()
{
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline int t_timed_event::get_first_occurrence() const
{
	return m_first_occurrence;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline int t_timed_event::get_recurrence_interval() const
{
	return m_recurrence_interval;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline void t_timed_event::set_first_occurrence( int new_first_occurrence )
{
	assert( new_first_occurrence >= 1 );
	m_first_occurrence = new_first_occurrence;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline void t_timed_event::set_recurrence_interval(
	int	new_recurrence_interval )
{
	assert( new_recurrence_interval >= 0 );
	m_recurrence_interval = new_recurrence_interval;
}

#endif // !defined( TIMED_EVENT_H_INCLUDED )
